#!/usr/bin/env python

__author__ = 'Emiliano Dalla Verde Marcozzi'
__version__ = '0.1'
__copyright__ = 'Licencia GPL v2'

import psi
import platform

class systemtool:
    """ Utility class to get info from the system
    """
    def loadaverage(self):
        """ Retrun the current load average as string
        """
        loadavg = "%0.2f,%0.2f,%0.2f" % psi.loadavg()
        return loadavg
        
    def machineprofile(self):
        """ Get specifications from the machine ...
        It uses platform from standard python library so it's
        multiplataform ... 
        """
        profile = {}
        profile['architecture'] = platform.architecture()
        profile['dist'] = platform.dist()
        profile['libc'] = platform.libc_ver()
        profile['machine'] = platform.machine()
        profile['node'] = platform.node()
        profile['platform'] = platform.platform()
        profile['processor'] = platform.processor()
        profile['python_build'] = platform.python_build()
        profile['python_compiler'] = platform.python_compiler()
        profile['python_version'] = platform.python_version()
        profile['system'] = platform.system()
        profile['uname'] = platform.uname()
        profile['version'] = platform.version()
        
        # when u are not a mac, platform.mac_ver returns (('', ('', '', ''), '')
        # so, if i am not a mac, don't add me to the dic ...
        if platform.mac_ver() is not '(('', ('', '', ''), '')':
            profile['mac_ver'] = platform.mac_ver()
        
        return profile
